<?php
/**
 * Created by PhpStorm.
 * User: lg
 * Date: 2017/12/7
 * Time: 10:51
 */

namespace app\bangding\controller;

class Base extends PublicController
{
    public $nick_name;
    public $openid;


    public function _initialize()
    {
        $this->nick_name = session('wechat.nickname');
        $this->openid = getOpenid();

//        //判断登陆状态
        if (!$this->checkLogin()) {
            session('id',input('id'));
            return $this->oauth()->redirect()->send();
        }
    }

    /**
     * 检查登陆状态
     */
    public function checkLogin()
    {
        if (!$this->openid) {
            return false;
        }
        return true;
    }

    /**
     * 登陆
     */
    public function toLogin()
    {
        if (input('code')) {

        } else {
            $this->oauth()->setRequest()->redirect()->send();
        }
    }
}